package com.oauth.twitter.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
import com.oauth.twitter.client.beans.Tweet;

public class TweetPanel extends Composite {

	private static TweetPanelUiBinder uiBinder = GWT
			.create(TweetPanelUiBinder.class);

	interface TweetPanelUiBinder extends UiBinder<Widget, TweetPanel> {
	}

	@UiField
	Image profileImage;

	@UiField
	HTML tweet;

	@UiField
	HTML user;

	@UiField
	HTML date;

	public TweetPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	public void initTweetPanel(Tweet pTweet) {
		profileImage.setUrl(pTweet.getUser().getProfileImageUrl());
		user.setHTML("<b><font color=\""
				+ pTweet.getUser().getProfileLinkColor() + "\">"
				+ pTweet.getUser().getName() + "</font></b>");

		tweet.setHTML("<p>" + pTweet.getText() + "</p>");
		date.setHTML("<i>" + pTweet.getCreatedDate() + "</i>");
	}
}